<?php


namespace app\mod\pcr\model;


use think\Model;

class PcrGveGroupFight extends Model {

    const TYPE_NORMAL = 0;
    const TYPE_END = 1;

    protected $table = 'pcr_gve_group_fight';

    public function getUserReportWithTimeRange($group_id, $user_id, $time_start, $time_end, $type) {
        return $this->where('group_id', $group_id)
            ->where('user_id', $user_id)
            ->where('created_at', 'BETWEEN', [$time_start, $time_end])
            ->where('type', $type)
            ->select();
    }

    public function getLastLog($group_id) {
        return $this->where('group_id', $group_id)
            ->order('created_at', 'desc')
            ->find();
    }

}